﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using SimpleFMMatrix.DataStructures;

namespace SimpleFMMatrix.ViewModel
{
    public class ModulationIndexVM : IntValuedDependencyObject
    {
        public static readonly DependencyProperty IsSelfFeedBackProperty =
            DependencyProperty.Register("IsSelfFeedBack", typeof(bool), typeof(ModulationIndexVM),
            new PropertyMetadata(false));

        public static readonly DependencyProperty OperatorNameProperty =
            DependencyProperty.Register("OperatorName", typeof(string), typeof(ModulationIndexVM),
            new PropertyMetadata(""));



        public bool IsSelfFeedBack
        {
            get { return (bool)GetValue(IsSelfFeedBackProperty); }
            set { SetValue(IsSelfFeedBackProperty, value); }
        }

        public string OperatorName
        {
            get { return (string)GetValue(OperatorNameProperty); }
            set { SetValue(OperatorNameProperty, value); }
        }



        internal ModulationIndexVM(FMMatrix matrix, int i, int j, Action updatePreview)
            : base(matrix.ModIndices[i, j], (o, n) =>
            {
                matrix.ModIndices[i, j] = n;
                updatePreview();
            })
        {
            if (i == j)
            {
                IsSelfFeedBack = true;
                OperatorName = ((char)('A' + i)).ToString();
            }
        }
    }
}
